<?php


namespace app\partneradmin\model;


use think\Model;

class UserQuota extends Model
{

    //自动写入时间
    protected $autoWriteTimestamp = true;

    /**
     * 时间格式化
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i:s';

    /**
     * 计算用户总贷款额度
     * @param $userId
     * @return float|int|string
     */
    public function sumQuota($userId)
    {
        $where = [
            'user_id' => $userId,
            'status' => 0,
            'is_del' => 0
        ];
        return self::where($where)->sum('quota');
    }
}